#pragma once

#include "d3d9.h"
#include "d3dx9.h"
#include "SpriteManager.h"
#include "DirectInput.h"
#include "Sound.h"
#include "HighScore.h"

// Add pragma comments so we do not have to change
// the project dependencies
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

class MainMenu
{
private:
	// Singleton instance
	static MainMenu*	m_MenuInstance;

	// Pointers to other classes
	SpriteManager*		m_pSpriteManager;
	HighScore*			m_pHighScore;
	Text*				m_pText;
	Sound*				m_pSound;

	// Sprite pointer
	ID3DXSprite*		m_pMainMenu;

	// Sprites that will show up on main menu
	short sTitleBar;
	short sPlayGame;
	short sCredits;
	short sInstructions;
	short sViewHighScore;
	short sQuit;
	short sLogo;
	short sMenuTerminal;
	short sMatrball;
	short sPlayPic;
	short sCreditPic;
	short sInstructionPic;
	short sHighscorePic;
	short sQuitPic;

	// Main Menu Highlight Sprites
	short sHPlayGame;
	short sHCredits;
	short sHInstructions;
	short sHHighScore;
	short sHQuit;
	
	// Instructions screens
	short sInstructionScreen;
	short sControls;
	short sGameModes;
	short sObjectives;
	short sObstacles;
	short sControlInstructions;
	short sObstacleInstructions;
	short sObjectiveInstructions;

	//Instructions HighlightSprites
	short sHControl;
	short sHObjectives;
	short sHObstacles;

	// Other screens & button
	short sHighScoreScreen;
	short sCreditScreen;
	short sBackButton;

	// States
	short sMenuState;
	enum eMenuState{MAINMENU, INSTRUCTIONS, CREDITS, HIGHSCORE, CONTROLS, OBJECTIVES, OBSTACLES};
	short sGameState;

	// Timers
	short sClickTimer;
	long lStartTime;
	long lCurrentTime;
	long lMilliseconds;
	long lTotalTime;

	// Sound loading variable
	bool	bSoundLoaded;

public:
	MainMenu(void);
	~MainMenu(void);

	// Singleton functions
	static MainMenu* GetInstance(void);
	void DeleteMenuInstance(void);

	void InitMainMenu(IDirect3DDevice9* m_pD3DDevice, HWND hWnd, HINSTANCE hInst);
	void Update(HWND hWnd, DirectInput* m_pDirectInput);
	void Render(IDirect3DDevice9* m_pD3DDevice);
	short GetStateMenu(void);
	void GetPlayGameHighlight(void);
	void GetCreditsHighlight(void);
	void GetInstructionsHighlight(void);
	void GetHighScoreHighlight(void);
	void GetQuitHighlight(void);
	void RemoveHighlights(void);
	// Shutdown
	void DestroyMenu(void);
};